<template>
  <div class='activity first-box'>
    <Search :searchFun="getSearch"></Search>
    <LineGray></LineGray>
    <Scroll :hasmore="hasmore" :pullup="pullup" setHeight="-60">
      <List :data="listData"></List>
    </Scroll>
  </div>
</template>
<script>
import Search from '../../../common/search'
import LineGray from '../../../common/line.vue'
import Scroll from '../../../common/scroller'
import List from "./common/list"
export default {
  components: {Search,LineGray,Scroll,List},
  name: "",
  data() {
    return {
      hasmore:false,
      listData:[
        {
          id:1,
          num:"123132131",
          date:"2018-5-12",
          img:"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=469272352,4280105280&fm=173&app=25&f=JPEG?w=218&h=146&s=F4F015C0DE6312842B81709A0300C090",
          title:"老用户的优惠",
          starttime:"2018-5-12",
          endtime:"2018-5-12",
          state:1,//1已确认，2待确认，3已发送
        },{
          id:1,
          num:"123132131",
          date:"2018-5-12",
          img:"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=469272352,4280105280&fm=173&app=25&f=JPEG?w=218&h=146&s=F4F015C0DE6312842B81709A0300C090",
          title:"老用户的优惠",
          starttime:"2018-5-12",
          endtime:"2018-5-12",
          state:3,//1已确认，2待确认，3已发送
        },{
          id:1,
          num:"123132131",
          date:"2018-5-12",
          img:"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=469272352,4280105280&fm=173&app=25&f=JPEG?w=218&h=146&s=F4F015C0DE6312842B81709A0300C090",
          title:"老用户的优惠",
          starttime:"2018-5-12",
          endtime:"2018-5-12",
          state:2,//1已确认，2待确认，3已发送
        }
      ]
    };
  },
  methods: {
    getSearch(search){
      console.log("click----search",search)
    },

    // 下拉刷新方法回调
    pullup(func){
      console.log("发请求了") 

      func()
    },
    getList(){
      var params={
        // userId:sessionStorage.getItem("userId")
      }
      _g.apiPost("vipMyOrder/activity.do",params).then(res=>{
        var goal=[]
        res.data.forEach(ele => {
          goal.push({
            id:ele.id,
            num:ele.orderNum,
            date:_g.formatTime(ele.orderDate),
            img:ele.picture||"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=469272352,4280105280&fm=173&app=25&f=JPEG?w=218&h=146&s=F4F015C0DE6312842B81709A0300C090",
            title:ele.activityTitle||"暂无",
            starttime:_g.formatTime(ele.startDate),
            endtime:_g.formatTime(ele.endTime),
            state:ele.state
          })
        });
        this.$set(this,"listData",goal)
      })
    }
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.activity {

}
</style>